package com.xinxin.leetcode.problem374;

/**
 * @author ShiXinXin
 * @date 2019-12-15 3:14
 */
public class Solution extends GuessGame {
    public int guessNumber(int n) {
        int s = 1, e = n;
        int mid = s + (e - s) / 2;
        while (s <= e) {
            mid = s + (e - s) / 2;
            if (guess(mid) == 0) {
                return mid;
            } else if (guess(mid) == 1) {
                s = mid + 1;
            } else {
                e = mid - 1;
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        System.out.println(new Solution().guessNumber(1));
    }
}
